package com.unytech.project.entity.system;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.unytech.project.entity.BaseEntity;

/**
 * 权限实体类
 * @author LONG
 *
 */
@Entity @Table(name="T_PERMISSION")
public class Permission extends BaseEntity {
	@Id @Column(length=12,unique=true)
	private String permid;
	
	@Column(length=32,nullable=false)
	private String permname;
//	private Integer permDepth;
	@Column(length=12,nullable=false)
	private String parentid;
	
	@Column(length=50,nullable=false)
	private String permuri = "#";
	
//	@Column(length=20,nullable=false)
//	private String permtype = GlobalEnum.ACCORDION.toString();
	@Transient
	private String permtype; 
	
	/** 权限排序索引 */
	@Column(nullable=true)
	private Integer permindex;
	
	/** 父权限 */
	@Transient
	private Permission parentperm;
	
	/** 子权限 */
	@Transient
	private Set<Permission> subPerms;
	
//	@ManyToMany(cascade=CascadeType.REFRESH,mappedBy="permissions")
//	private Set<PermissionGroup> permGroup = new HashSet<PermissionGroup>();  //与权限组之间的多对多关系映射
	
	public String getPermid() {
		return permid;
	}
	public void setPermid(String permid) {
		this.permid = permid;
	}	
	public String getPermname() {
		return permname;
	}
	public void setPermname(String permname) {
		this.permname = permname;
	}
	public String getParentid() {
		return parentid;
	}
	public void setParentid(String parentid) {
		this.parentid = parentid;
	}
	public String getPermuri() {
		return permuri;
	}
	public void setPermuri(String permuri) {
		this.permuri = permuri;
	}
	public String getPermtype() {
		return permtype;
	}
	public void setPermtype(String permtype) {
		this.permtype = permtype;
	}
	public Integer getPermindex() {
		return permindex;
	}
	public void setPermindex(Integer permindex) {
		this.permindex = permindex;
	}
	public Set<Permission> getSubPerms() {
		return subPerms;
	}
	public void setSubPerms(Set<Permission> subPerms) {
		this.subPerms = subPerms;
	}
//	public void setPermGroup(Set<PermissionGroup> permGroup) {
//		this.permGroup = permGroup;
//	}
//	public Set<PermissionGroup> getPermGroup() {
//		return permGroup;
//	}
	public Permission getParentperm() {
		return parentperm;
	}
	public void setParentperm(Permission parentperm) {
		this.parentperm = parentperm;
	}
}
